﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Configuration;
//using System.Globalization;
//using Microsoft.Practices.Unity;
//using Microsoft.Practices.Unity.InterceptionExtension;
//using Microsoft.Practices.Unity.Configuration;

//namespace Twi.COMMON.Core
//{
//    /*
//     * CopyRight:©2012 Twilight软件开发工作室版权所有
//     * Author:xuzhihong
//     * Create Date: 2012-07-02
//     * Description: Unity接口和实现对应配置读取
//     */
//    public static class ServiceLoader
//    {
//        private static readonly TransparentProxyInterceptor injector = new TransparentProxyInterceptor();

//        public static IUnityContainer Container
//        { get; private set; }

//        static ServiceLoader()
//        {
//            UnityConfigurationSection unitySection = ConfigurationManager.GetSection("unity") as UnityConfigurationSection;
//            if (unitySection == null)
//            {
//                throw new ConfigurationErrorsException(string.Format(CultureInfo.CurrentCulture, "Missing Unity configuration section."));
//            }

//            Container = new UnityContainer();
//            ContainerElement containerElement;
//            containerElement = unitySection.Containers.Default;
//            unitySection.Configure(Container);
//            Container.AddNewExtension<Interception>();
//        }

//        public static T LoadService<T>()
//        {
//            Container.Configure<Interception>().SetDefaultInterceptorFor(typeof(T), injector);
//            return Container.Resolve<T>();
//        }

//        public static T LoadService<T>(string serviceName)
//        {
//            Container.Configure<Interception>().SetDefaultInterceptorFor(typeof(T), injector);
//            return Container.Resolve<T>(serviceName);
//        }
//    }
//}
